package com.acarter.scenemonitor.propertydescriptor.enums;

/**
 * <p>Title</p>
 * 
 * <p>Description: </p>
 *
 * <p>Copyright (c) 2007</p>
 *
 * @author Andrew Carter
 * @version 
 */

/**
 * Enumerates the permissible render state types.
 * 
 * @author Andrew Carter
 */
public enum E_RenderState {

    /** The value returned by getType() for AlphaState. */
    RS_ALPHA("Alpha State", 0),

    /** The value returned by getType() for AttributeState. */
    RS_ATTRIBUTE("Attribute State", 12),

    /** The value returned by getType() for ClipState. */
    RS_CLIP("Clip State", 16),

    /** The value returned by getType() for ColorMaskState. */
    RS_COLORMASK_STATE("Color Mask State", 15),

    /** The value returned by getType() for CullState. */
    RS_CULL("Cull State", 9),

    /** The value returend by getType() for DitherState. */
    RS_DITHER("Dither State", 1),

    /** The value returned by getType() for FogState. */
    RS_FOG("Fog State", 2),

    /** The value returned by getType() for FragmentProgramState. */
    RS_FRAGMENT_PROGRAM("Fragment Program State", 11),

    /** The value returned by getType() for ShaderObjectsState. */
    RS_GLSL_SHADER_OBJECTS("GLSL Shader Objects State", 14),

    /** The value returned by getType() for LightState. */
    RS_LIGHT("Light State", 3),

    /** The value returend by getType() for MaterialState. */
    RS_MATERIAL("Material State", 4),

    /** The value returned by getType() for ShadeState. */
    RS_SHADE("Shade State", 5),

    /** The value returned by getType() for StencilState. */
    RS_STENCIL("Stencil State", 13),

    /** The value returned by getType() for TextureState. */
    RS_TEXTURE("Texture State", 6),

    /** The value returned by getType() for VertexProgramState. */
    RS_VERTEX_PROGRAM("Vertex Program State", 10),

    /** The value returned by getType() for WireframeState. */
    RS_WIREFRAME("Wireframe State", 7),

    /** The value returned by getType() for ZBufferState. */
    RS_ZBUFFER("Z-Buffer State", 8);

    /** String representation of the enum value */
    private String name;

    /** Integer value of the enum value */
    private int value;

    /**
     * Private constructor.
     * 
     * @param value
     *                String literal of the enum
     */
    private E_RenderState(String name, int value) {

	this.name = name;
	this.value = value;
    }

    /**
     * Returns the enum constant matching the name string.
     * 
     * @param name
     *                string value of enum constant
     * @return matching enum constant or null
     */
    public static E_RenderState getConstant(String name) {

	for(E_RenderState constant : E_RenderState.values()) {

	    if(constant.toString().compareToIgnoreCase(name) == 0)
		return constant;
	}

	return null;
    }

    /**
     * Returns the enum constant matching the type value.
     * 
     * @param type
     *                type value of enum constant
     * @return matching enum constant or null
     */
    public static E_RenderState getConstant(int type) {

	for(E_RenderState constant : E_RenderState.values()) {

	    if(constant.getType() == type)
		return constant;
	}

	return null;
    }

    /**
     * Returns the string value of the constant.
     */
    public String toString() {

	return name;
    }

    /**
     * Returns the integer value of the constant.
     * 
     * @return
     */
    public int getType() {

	return value;
    }
}
